﻿using System;

namespace Minesweeper
{
    public class LevelHandler
    {
        public void CreateLevelMenu()
        {
            string menuSpace = new string(' ', 28);
            string subMenuSpace = new string(' ', 33);

            Console.WriteLine("{0} Please select level", menuSpace);

            foreach (Level level in (Level[])Enum.GetValues(typeof(Level)))
            {
                Console.WriteLine("{0} {1} {2}", subMenuSpace, "*", level.ToString());
            }
        }

        public LevelData GenerateLevelData(Level level)
        {
            switch (level)
            {
                case Level.Beginner:
                    {
                        return new LevelData(9, 9, 10);
                    }
                case Level.Intermediate:
                    {
                        return new LevelData(16, 16, 40);
                    }
                case Level.Expert:
                    {
                        return new LevelData(16, 30, 99);
                    }
            }

            // This should never happen
            throw new InvalidOperationException("The selected level is not valid.");
        }
    }
}
